﻿{extend name="common/inside"}

{block name="table"}
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
        <a href="javascript:;" onclick="member_add('添加点劵','{:url('/point/create')}','','440')" class="btn btn-primary radius"><i
                class="Hui-iconfont">&#xe600;</i> 添加点劵</a></span>
        <span class="r">共有数据：<strong>88</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th>序号</th>
                <th>点券名称</th>
                <th>点劵价格</th>
                <th>操作</th>

            </tr>
            </thead>
            <tbody>
            {foreach $points as $point}
            <tr class="text-c">
                <td>{$point->point_id}</td>
                <td>{$point->point_name}</td>
                <td>{$point->point_price}</td>
                <td class="td-manage">
                    <a style="text-decoration:none" onClick="member_stop(this,'10001')" href="javascript:;"
                       title="停用"><i class="Hui-iconfont">&#xe631;</i></a>
                    <a title="编辑" href="javascript:;" onclick="member_edit('点劵编辑','{:str_replace('id',$point->point_id,url('/point/id/edit'))}','4','','440')"
                       class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    <a style="text-decoration:none" class="ml-5"
                       onClick="change_password('修改密码','change-password.html','10001','600','270')" href="javascript:;"
                       title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
                    <a title="删除" href="javascript:;" onclick="member_del(this,{$point->point_id})" class="ml-5"
                       style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
    </div>
</div>

{/block}


{block name='js'}
<script>

    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){

            var url = "{:url('/point/id')}"
            console.log(url)
            url = url.replace('id',id)

            console.log(url)
            $.ajax({
                type: 'DELETE',
                url: url,
                datapoint: 'json',
                success: function(data){
                    console.log(data)
                    if (data.state == 'success'){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    } else {
                        layer.msg('删除失败!',{icon:2,time:1000});
                    }

                },
                error:function(data) {
                    console.log(data)

                    // console.log(data.msg);
                },
            });
        });
    }

</script>

{/block}




